package com.itheima.mapper;

import com.itheima.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;

@Mapper
public interface OrderMapper {

    @Select("select * from t_order where id = #{id}")
    Order findById(Integer id);

    @Select("select * from t_order where member_id = #{memberId} and orderDate = #{orderDate}")
    Order findByMemberIdAndOrderDate(Integer memberId, LocalDate orderDate);

    @Insert("insert into t_order(member_id, orderDate, orderType, orderStatus, setmeal_id) " +
            "values(#{memberId}, #{orderDate}, #{orderType}, #{orderStatus}, #{setmealId})")
    void add(Order order);
}
